package com.android.newsreader;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* Class for representing an RSS Feed
* it implements Serializable so that objects of this 
* type can be passed as extras in 'Intents'
*  
*/
public class RSSChannel implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8401015206412762039L;
	
	private String mURL = null;
	private String mCategory = null;
	private String mName = null;
	
	
	public RSSChannel(String name, String category, String url)
	{
		mURL = url;
		mCategory = category;
		mName = name;
	}
	
	
	/** 
	 * Standard Getters and Setters
	 */
	
	public void setCategory(String category)
	{
		mCategory = category;
	}
	
	public String getCategory()
	{
		return mCategory;
	}
	
	public void setURL(String url)
	{
		mURL = url;
	}
	
	public String getURL()
	{
		return mURL;
	}
	
	public String getName()
	{
		return mName;
	}
	
	public void setName(String name)
	{
		mName = name;
	}
	
	/**
	* Utility method for creating
	* RSSChannel objects from | delimited strings
	*   
	*/
	public static RSSChannel getChannel(String channelString){
		
		String delims = "[|]+";
		String[] tokens = channelString.split(delims);
		
		String name = tokens[0];
		String category = tokens[1];
		String url = tokens[2];
		
		return  new RSSChannel(name, category, url);
	}
}
